package com.example.day20_zhongji.fragment;


import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ExpandableListView;

import androidx.fragment.app.Fragment;

import com.example.day20_zhongji.R;
import com.example.day20_zhongji.adapter.Listadapter;

import java.util.ArrayList;
import java.util.List;

/**
 * A simple {@link Fragment} subclass.
 */
public class ListlFragment extends Fragment {


    private ExpandableListView mList1;

    public ListlFragment() {
        // Required empty public constructor
    }


    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        View view = inflater.inflate(R.layout.fragment_list, container, false);
        initViews(view);
        return view;

    }

    private void initViews(View view) {
        ArrayList<String> strings = new ArrayList<>();
        strings.add("列表①");
        strings.add("列表②");
        strings.add("列表③");
        ArrayList<List<String>> lists = new ArrayList<>();
        List<String> list1 = new ArrayList<String>();
        list1.add(" 虞姬");
        list1.add(" 甄姬");
        list1.add(" 阿狸");
        list1.add(" 狐狸");
        List<String> list2 = new ArrayList<String>();
        list2.add(" 李白");
        list2.add(" 項羽");
        list2.add(" 荊軻");
        list2.add(" 曹操");
        List<String> list3 = new ArrayList<String>();
        list3.add(" 公孙离");
        list3.add(" 孙尚香");
        list3.add(" 狄仁杰");
        list3.add(" 蔡文姬");
        lists.add(list1);
        lists.add(list2);
        lists.add(list3);
        Listadapter listadapter = new Listadapter(strings, lists, getContext());
        mList1 = view.findViewById(R.id.list_1);
        mList1.setAdapter(listadapter);
    }
}
